class_name FSM
extends Base1

var states_array:Array=[]
@onready var current :Base1=$move
@onready var animated =$"../Graphics/AnimatedSprite2D"
@onready var monster = $".."
func _ready():
	self.add_to_group("monster")
	states_array=get_children()
	current.enter()
	pass

func _physics_process(delta):
	if monster.velocity.x< 0:
		animated.play("left")
	elif( monster.velocity.x> 0):
		animated.play("right")
	elif(monster.velocity.y< 0):
		animated.play("up")
	elif monster.velocity.y> 0:
		animated.play("down")
	current.do()
	pass
#状态转换函数
func change_state(id:int)->void:
	current.exit() #老状态退出
	current=states_array[id]
	current.enter()
	pass
